

#include <aiocb.h>

struct aiocb {
    /* The order of these fields is implementation-dependent */

    int             aio_fildes;     /* File descriptor */
    off_t           aio_offset;     /* File offset */
    volatile void  *aio_buf;        /* Location of buffer */
    size_t          aio_nbytes;     /* Length of transfer */
    int             aio_reqprio;    /* Request priority */
    struct sigevent aio_sigevent;   /* Notification method */
    int             aio_lio_opcode; /* Operation to be performed;
                                       lio_listio() only */

    /* Various implementation-internal fields not shown */
};

/* Operation codes for 'aio_lio_opcode': */

enum { LIO_READ, LIO_WRITE, LIO_NOP };

union sigval {          /* Data passed with notification */
    int     sigval_int;     /* Integer value */
    void   *sigval_ptr;     /* Pointer value */
};

struct sigevent {
    int             sigev_notify;   /* Notification method */
    int             sigev_signo;    /* Notification signal */
    union sigval    sgiev_value;    /* Data passed with notification */
    void            (*sigev_notify_function) (union sigval);
                    /* Function used for thread
                     * notification (SIGEV_THREAD) */
    void            *sigev_notify_attributes;
                    /* Attributes for notification thread
                     * (SIGEV_THREAD) */
    pid_t           sigev_notify_thread_id;
                    /* ID of thread to signal (SIGEV_THREAD_ID) */

};


#include <aio.h>

int aio_read(struct aiocb *aiocbp);
int aio_write(struct aiocb *aiocbp);

int aio_fsync(int op, struct aiocb *aiobp);

int aio_error(const struct aiocb *aiocbp);

ssize_t aio_return(struct aiocb *aiocbp);

int aio_suspend(const struct aiocb * const aiocb_list[],
                int nitems, const struct timespec *timeout);

int aio_cancel(int fd, struct aiocb *aiocbp);

int lio_listio(int mode, struct aiocb *const aiocb_list[],
               int nitems, struct sigevent *sevp);
